<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
    
    <script type="text/javascript">
    var msgactiongrid;
	//图像
	var msgaction_tu = function(id, name, clas) {

		var te = "<span onclick='"+id+"' style='margin-left:3px;cursor:pointer;'>【"
				+ "" + name + "】</span>";
		return te;
	}
	
	$(function() {
		msgactiongrid = $('#msgactiongrid').datagrid(
				{
					//title : '自动回复',
					url : '${ctx}/wxsys/msgaction/list',
					striped : true,
					rownumbers : true,
					pagination : true,
					singleSelect : true,
					idField : 'id',
					//sortName : 'create_date',
					sortOrder : 'desc',
					pageSize : 50,
					pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
			
					columns : [ [
					             {
					            	 width:'160',
					            	 title:'关键字',
					            	 field:'key_word'
					             },
					             {
					            	 width:'160',
					            	 title:'动作响应类型',
					            	 field:'name'
					             },
							{
								width : '150',
								title : '编辑时间',
								field : 'in_time'
								
							},
							
							{
								title : '操作',
								field : 'action',
								width : '160',
								formatter : function(value, rows) {
									var str = '';
									
									str += msgaction_tu("msgactionremoveFun(\"" + rows.id
											+ "\")", "删除", "icon-no");
								
									return str;
								}
							} ] ],
					toolbar : '#msgactiontoolbar',
					onBeforeLoad : function(param) {
						parent.$.messager.progress({
							text : '数据加载中....'
						});
					},
					onLoadSuccess : function(data) {
						$('.iconImg').attr('src', sy.pixel_0);
						parent.$.messager.progress('close');
					}
				});
	});

	
	//删除
	var msgactionremoveFun = function(id) {
		parent.$.messager.confirm('询问', '您确定要删除此记录？', function(r) {
			if (r) {
				$.post('${ctx}/wxsys/msgaction/delte/' + id, {
					id : id
				}, function() {
					msgactiongrid.datagrid('reload');
				}, 'json');
			}
		});
	};
	//添加
	var msgactionaddFun = function() {
		$('<div/>').dialog({
			href : '${ctx}/sys/user/adupdate/pro',
			width : 640,
			height : 290,
			modal : true,
			title : '添加消息',
			buttons : [ {
				text : '添加',
				iconCls : 'icon-add',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#user_updateForms').form('submit', {
						url : '${ctx}/sys/user/adupdate',
						success : function(result) {
							try {
								var r = $.parseJSON(result);
								if (r.success) {

									usergrid.datagrid('reload'); // 刷新数据  
									d.dialog('destroy');
								}
								$.messager.show({
									title : '温馨提示',
									msg : r.message
								});

							} catch (e) {
								$.messager.alert('温馨提示', r.message);
								return;
							}

						}

					});
				}

			} ],
			onLoad : function() {
				//$("#res_updateForm").form('load',entity);
			}
		});

	};

	//修改
	var msgactionupdateFun = function(id) {
		$('<div/>').dialog({
			href : '${ctx}/sys/user/adupdate/pro?id=' + id,
			width : 640,
			height : 290,
			modal : true,
			title : '修改用户',
			buttons : [ {
				text : '修改',
				iconCls : 'icon-add',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#user_updateForms').form('submit', {
						url : '${ctx}/sys/user/adupdate',
						success : function(result) {
							try {
								var r = $.parseJSON(result);
								if (r.success) {
  
									msgactiongrid.datagrid('reload'); // 刷新数据  
									d.dialog('destroy');
								}
								$.messager.show({
									title : '温馨提示',
									msg : r.message
								});

							} catch (e) {
								$.messager.alert('温馨提示', r.message);
								return;
							}

						}

					});
				}

			} ],
			onLoad : function() {
				//$("#res_updateForm").form('load',entity);
			},
			onClose : function() {
				$(this).dialog('destroy');
			}
		});

	};

	
</script>





<!-- 界面布局  -->
<div class="easyui-layout" style="width: 100%; height: 100%;"
	data-options="fit:true,border:false">
	
<div id="msgactiontoolbar" style="display: none;">

		<table>
			<tr>
				<td>
					<form id="msgactionsearchForm">
						<table>
							<tr style="font-size: 13px;">
								
								<td>关键字</td>
								<td><input name="QUERY_t#name_S_LK" style="width: 80px;" /></td>
								
								<td>创建时间</td>
								<td><input name="QUERY_t#createdatetime_D_GE" class="Wdate"
									onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
									readonly="readonly" style="width: 120px;" />-<input
									name="QUERY_t#createdatetime_D_LE" class="Wdate"
									onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
									readonly="readonly" style="width: 120px;" /></td>
								<td><a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search',plain:true"
									onclick="usergrid.datagrid('load',sy.serializeObject($('#usersearchForm')));">过滤</a><a
									href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-reload',plain:true"
									onclick="$('#usersearchForm input').val('');usergrid.datagrid('load',{});">重置过滤</a></td>
							</tr>
						</table>
					</form>
				</td>
			</tr>
			<tr>
				<td>
					<table>
						<tr>
							
								<td><a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-add',plain:true"
									onclick="useraddFun();">添加</a></td>
						
							
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</div>
	 
	<div data-options="region:'center',title:'自动回复消息'" style="padding: 2px;">
		<div class="easyui-layout" data-options="fit : true,border : false">
			<div data-options="region:'center',border:false">
				<table id="msgactiongrid" data-options="fit:true,border:false"></table>
			</div>
		</div>
	</div>
	
</div>